import { _decorator, Component, director, Node } from 'cc';
import { Core } from '../core/Core';
import { ProgressBar } from './ProgressBar';
const { ccclass, property } = _decorator;

@ccclass('Start')
export class Start extends Component {

    @property(Node)
    progressBar: Node;

    start() {
        console.log('stat stat');

        Core.instance.init(() => {
            director.preloadScene('Main', (completedCount: number, totalCount: number, item: any) => {
                if (totalCount > 0) {
                    this.progressBar.getComponent(ProgressBar).setProgress(completedCount / totalCount);
                }
            }, () => {
                // this.scheduleOnce(() => director.loadScene('Main'), 3)
                director.loadScene('Main');
            })
        });


    }

    update(deltaTime: number) {

    }
}


